package com.woniu.controller;

import com.woniu.entity.UserAppCategory;
import com.woniu.entity.response.ResponseEntity;
import com.woniu.service.IUserAppCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hyl
 * @since 2022-08-28
 */
@RestController
@RequestMapping("/brain/userAppCategory")
@CrossOrigin(allowCredentials = "true", originPatterns = "*")
public class UserAppCategoryController {
    @Autowired
    private IUserAppCategoryService userAppCategoryService;

    /*/**
     *@description 增加userAppCategory
     *@params [userAppCategory]
     *@return_value com.woniu.entity.response.ResponseEntity
     *@author hyl
     *@date 2022/8/30
     */
    @RequestMapping("/addOrUpdate")
    public ResponseEntity addUserAppCategory(UserAppCategory userAppCategory) {
        userAppCategoryService.saveOrUpdate(userAppCategory);
        return ResponseEntity.success(userAppCategory);
    }

    /*/**
     *@description 物理删除userAppCategory
     *@params [userAppCategoryId]
     *@return_value com.woniu.entity.response.ResponseEntity
     *@author hyl
     *@date 2022/8/30
     */
    @RequestMapping("/del/{userAppCategoryId}")
    public ResponseEntity delUserAppCategory(@PathVariable Integer userAppCategoryId) {
        userAppCategoryService.removeById(userAppCategoryId);
        return ResponseEntity.success(null);
    }
    /*/**
     *@description 获取类别列表
     *@params []
     *@return_value com.woniu.entity.response.ResponseEntity
     *@author hyl
     *@date 2022/9/6
     */
    @RequestMapping("/list")
    public ResponseEntity getAllUserAppCategory() {
        return ResponseEntity.success(userAppCategoryService.list());
    }
}
